//-----------------------------------------------------------------------
// <copyright file="tblCurrencyInOpicDAO.cs" company="Scb">
//     Copyright ? Scb. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
	
using System;
using System.Data;
using System.Data.Common;
using Robot.Entities;
using Scb.Framework;
using Scb.Framework.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Robot.Data
{	
	public class tblCurrencyInOpicDAO : tblCurrencyInOpicDAOBase
	{
		public tblCurrencyInOpicDAO()
		{
    }

    #region My Store Procedure

    public virtual tblCurrencyInOpic GettblCurrencyInOpicByCCY(string sBuyCCY, string sSellCCY)
    {
      try
      {
        Database database = DatabaseFactory.CreateDatabase();
        DbCommand dbCommand = database.GetStoredProcCommand("_sptblCurrencyInOpicsGet");

        database.AddInParameter(dbCommand, "@BuyCCY", DbType.AnsiString, sBuyCCY);
        database.AddInParameter(dbCommand, "@SellCCY", DbType.AnsiString, sSellCCY);

        tblCurrencyInOpic tblCurrencyInOpic = null;
        using (IDataReader reader = DataAccessHelper.ExecuteReader(database, dbCommand))
        {
          if (reader.Read())
          {
            tblCurrencyInOpic = CreatetblCurrencyInOpicFromReader(reader);
            reader.Close();
          }
        }
        return tblCurrencyInOpic;
      }
      catch (Exception ex)
      {
        // log this exception
        Logger.Error(ex);
        // wrap it and rethrow
        throw new DataAccessException(SR.DataAccessGettblCurrencyInOpicException, ex);
      }
    }

    #endregion
  }
}
